using UnityEngine;
using UnityEditor;
using System.Collections;

public class lwBasicOrthoCamSetup : Editor
{
	[MenuItem("Tools/LWS/Ortho Camera Setup")]
	static void Create()
	{
		GameObject rootGo = new GameObject("SizingCamera");
		rootGo.transform.position = Vector3.zero;
		rootGo.transform.rotation = Quaternion.identity;
		
		GameObject renderCameraGo = new GameObject("RenderCamera");
		renderCameraGo.transform.parent = rootGo.transform;
		renderCameraGo.transform.localPosition = Vector3.zero;
		renderCameraGo.transform.localRotation = Quaternion.identity;

		GameObject faderGo = new GameObject("Fader");
		faderGo.transform.parent = rootGo.transform;
		faderGo.transform.localPosition = Vector3.forward / 100.0f;
		faderGo.transform.localRotation = Quaternion.identity;
		lwFader fader = faderGo.AddComponent<lwFader>();
		fader.m_pSprite = faderGo.GetComponent<Sprite>();
		MeshRenderer meshRenderer = faderGo.GetComponent<MeshRenderer>();
		meshRenderer.sharedMaterial = AssetDatabase.LoadAssetAtPath("Shared/Lws/lwFader/lwFader.mat", typeof(Material)) as Material;

		Camera RenderCam = renderCameraGo.AddComponent<Camera>();
		RenderCam.orthographic = true;
		RenderCam.orthographicSize = 384;//basic setup for 1024*768

		Camera SizingCam = rootGo.AddComponent<Camera>();
		SizingCam.clearFlags = CameraClearFlags.Nothing;
		SizingCam.cullingMask = 0;//render nothing
		SizingCam.orthographic = true;
		SizingCam.orthographicSize = 384;//basic setup for 1024*768
		SizingCam.renderingPath = RenderingPath.VertexLit;
		SizingCam.tag = "MainCamera";
		rootGo.AddComponent<lwSizeAdapter>();		
	}
}
